from minio import Minio
from app.core.config import settings

class MinioClientWrapper:
    _instance = None

    @classmethod
    def get_client(cls) -> Minio:
        """
        获取 MinIO 客户端单例
        """
        if cls._instance is None:
            cls._instance = Minio(
                settings.MINIO_ENDPOINT,
                access_key=settings.MINIO_ACCESS_KEY,
                secret_key=settings.MINIO_SECRET_KEY,
                secure=settings.MINIO_SECURE,
            )
        return cls._instance

# 便捷使用的函数
def get_minio_client() -> Minio:
    return MinioClientWrapper.get_client()